package com.qf.mybatisExam01.utils;

import cn.hutool.core.io.FileUtil;
import com.qf.mybatisExam01.entity.Book;

import java.util.ArrayList;
import java.util.List;

public class BookWriter {
    private String filePath;

    public BookWriter(String filePath) {
        this.filePath = filePath;
    }

    public void bookToFile(List<Book> books){
        List<String> list = new ArrayList<>();
        for (Book book : books) {
            String csv = book.toCSVString();
            list.add(csv);
        }
        FileUtil.appendLines(list,filePath,"utf-8");
    }
}
